package com.ziven.common.widget.value;

import android.view.View;

import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;

import com.ziven.easygo.util.ViewHelper;

/**
 * @author Ziven
 */
public final class TextColor extends Value {

    public static TextColor colorId(@ColorRes int colorId) {
        return new TextColor().accept(my -> my.resId = colorId);
    }

    public static TextColor color(@ColorInt int color) {
        return new TextColor().accept(my -> my.value = color);
    }

    private TextColor() {}

    @Override
    protected void takeEffect(@NonNull ViewHelper<? extends View> helper) {
        if(resId == 0) {
            value(Integer.class, helper::setTextColor);
        } else {
            helper.setTextColorId(resId);
        }
    }
}
